﻿using System;
using Pixysoft.Framework.XSchEmA;
using System.Data;
using System.Collections.Generic;
using Pixysoft.Framework.XSchEmA.Entity;
namespace Pixysoft.Framework.Noebe
{
    public interface INoebeDatabaseCloner
    {
        /// <summary>
        /// 两个数据库之间导数据。根据外键关系，先删除外键表数据，在插入数据。
        /// </summary>
        /// <param name="fromconfig"></param>
        /// <param name="toconfig"></param>
        void DataClone(NoebeConfiguration fromconfig, NoebeConfiguration toconfig);

        /// <summary>
        /// 两个数据库之间导数据。根据外键关系，先删除外键表数据，在插入数据。
        /// </summary>
        /// <param name="frommanager"></param>
        /// <param name="tomanager"></param>
        /// <param name="toDbtype"></param>
        void DataClone(INoebeManager frommanager, INoebeManager tomanager, DatabaseType toDbtype);


        /// <summary>
        /// 根据输入的table导入目标数据库，参考外键关系。
        /// </summary>
        /// <param name="config"></param>
        /// <param name="datas"></param>
        /// <returns></returns>
        void DataImport(NoebeConfiguration config, params DataTable[] datas);

        /// <summary>
        /// (远程)根据输入的table导入目标数据库，参考外键关系。
        /// </summary>
        /// <param name="manager"></param>
        /// <param name="datas"></param>
        /// <returns></returns>
        void DataImport(INoebeManager manager, DatabaseType databaseType, params DataTable[] datas);



        /// <summary>
        /// 根据输入的table 单表导入目标数据库，主要考虑到自增约束无法导入问题
        /// </summary>
        /// <param name="manager"></param>
        /// <param name="databaseType"></param>
        /// <param name="tables"></param>
        void DataRewrite(INoebeManager manager, DatabaseType databaseType, DataTable table);


        /// <summary>
        /// 导表结构
        /// </summary>
        /// <param name="fromconfig"></param>
        /// <param name="toconfig"></param>
        void StructClone(NoebeConfiguration fromconfig, NoebeConfiguration toconfig);



        /// <summary>
        /// 针对sqlserver的unique的问题，不允许非空，因此全部转移为index
        /// </summary>
        /// <param name="fromconfig"></param>
        /// <param name="toconfig"></param>
        void UniqueToIndexStructClone(NoebeConfiguration fromconfig, NoebeConfiguration toconfig);

        /// <summary>
        /// 针对sqlserver的unique的问题，不允许非空，因此全部转移为index
        /// </summary>
        /// <param name="odbschema"></param>
        /// <param name="odbtype"></param>
        /// <param name="toconfig"></param>
        void UniqueToIndexStructClone(DatabaseSchema odbschema, DatabaseType odbtype, NoebeConfiguration toconfig);
    }

    interface INoebeCloneResult
    {
        string[] FailTables { get;}
        string Log { get;}
        bool Succeed { get;}
    }
}
